$(function () {
    /*----------------------------------------- 获取所有板块信息 -----------------------------------------*/
    $.ajax({
        url: APP_PATH + "/getBlockList.action",
        type: "get",
        dataType: "json",
        success: function (data) {
            // 状态码
            // alert(data.code);
            var code = data.code;
            // 提示信息
            var msg = data.msg;
            if (code == 0) {
                // 板块展示
                getPlate(data.data);
            } else if (code == -1) {
                layer.msg(msg, {icon: 5});
            }
        },
        error: function () {
            layer.msg("出错！", {icon: 5});
        }
    });
    /*----------------------------------------- 获取所有板块信息-end -----------------------------------------*/

    /*----------------------------------------- 获取当前公告 -----------------------------------------*/
    $.ajax({
        url: APP_PATH + "/getNotice.action",
        type: "get",
        dataType: "json",
        success: function (data) {
            // 状态码
            var code = data.code;
            // 提示信息
            var msg = data.msg;
            if (code == 0) {
                // 热门文章
                getNotice(data.data);
            } else if (code == 500) {
                layer.msg(msg, {icon: 5});
            }
        },
        error: function () {
            layer.msg("出错！", {icon: 5});
        }
    });
    /*----------------------------------------- 获取热门文章信息-end -----------------------------------------*/

    /*----------------------------------------- 获取友情链接 -----------------------------------------*/
    $.ajax({
        url: APP_PATH + "/getFriendlyLink.action",
        type: "get",
        dataType: "json",
        success: function (data) {
            // 状态码
            // alert("200");
            var code = data.code;
            // 提示信息
            var msg = data.msg;
            if (code == 0) {
                // 热门文章
                getLink(data.data);
            } else if (code == 500) {
                layer.msg(msg, {icon: 5});
            }
        },
        error: function () {
            layer.msg("出错！", {icon: 5});
        }
    });
    /*----------------------------------------- 获取最新评论信息-end -----------------------------------------*/
})
/*跳转到文章详情（新开一个tab）*/
function skipArticle(fid) {
    var url = APP_PATH + '/article.jsp?fid=' + fid;
    window.open(url,"_blank");
}
/*跳转到公告（新开一个tab）*/
function skipNotice(nid) {
    var url = APP_PATH + '/notice.jsp?nid=' + nid;
    window.open(url,"_blank");
}
//根据参数名获取对应的url参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
